#ifndef _XML_PARSER_H
#define _XML_PARSER_H

#include "tinyxml2/tinyxml2.h"
#include <string>

typedef tinyxml2::XMLElement TiXmlElement;
typedef tinyxml2::XMLComment TiXmlComment;
typedef tinyxml2::XMLUnknown TiXmlUnknown;
typedef tinyxml2::XMLAttribute TiXmlAttribute;
typedef tinyxml2::XMLText TiXmlText;
typedef tinyxml2::XMLDeclaration TiXmlDeclaration;
typedef tinyxml2::XMLDocument TiXmlDocument;
typedef tinyxml2::XMLPrinter TiXmlPrinter;
typedef tinyxml2::XMLHandle TiXmlHandle;

class ctXML
{
        public:
                ctXML();
                ~ctXML();
                bool init(const char *filename, const char *servernodename);
                const TiXmlElement* rootElement();
                const TiXmlElement* getChildElement(const TiXmlElement *parent, const char* childname);
                const TiXmlElement* getNextElement(const TiXmlElement *element, const char* nextname);
                bool getElementPropNum(const TiXmlElement *element, const char* name, void* prop, const int size);
                bool getElementContextNum(const TiXmlElement *element, const char* name, void* prop, const int size);
                const char *getElementPropStr(const char *nodename, const char *propname);
                const char *getElementContextStr(const char *nodename);
                static std::string encodeString(std::string strData);
                static std::string decodeString(std::string strData);

        private:
                bool myInit(const char *filename, const char *servernode);
                static std::string replaceString(std::string strData, std::string regex, std::string replacement);
                TiXmlDocument *doc;
                std::string globalnodename;
                std::string servernodename;
};
#endif

